package data;

import java.util.Random;

// ===================== 设备状态类 =====================
public class MachineStatus {
    private String position;
    private String state;
    private int fuelLevel;
    private String currentTask;
    private double workingHours;
    private String maintenanceStatus;
    private static final Random random = new Random(); // 用于生成随机土壤数据
    public MachineStatus() {
        updateRandomStatus();
    }

    public void updateRandomStatus() {
        // 随机位置（A1-E5）
        char area = (char)('A' + random.nextInt(5));
        int row = 1 + random.nextInt(5);
        this.position = "" + area + row;

        // 随机状态
        String[] states = {"空闲", "工作中", "维护中"};
        this.state = states[random.nextInt(states.length)];

        // 随机油量
        this.fuelLevel = 20 + random.nextInt(80);

        // 随机任务
        String[] tasks = {"无", "播种-A区", "收割-B区", "喷洒-C区", "耕地-D区"};
        this.currentTask = tasks[random.nextInt(tasks.length)];

        // 随机工作时间
        this.workingHours = random.nextDouble() * 100;

        // 随机维护状态
        String[] maintenance = {"正常", "需保养", "需检查"};
        this.maintenanceStatus = maintenance[random.nextInt(maintenance.length)];
    }

    public void assignTask(String task) {
        this.currentTask = task;
        this.state = "工作中";
    }

    public String getPosition() {
        return position;
    }

    public String getState() {
        return state;
    }

    public int getFuelLevel() {
        return fuelLevel;
    }

    public String getCurrentTask() {
        return currentTask;
    }

    public double getWorkingHours() {
        return workingHours;
    }

    public String getMaintenanceStatus() {
        return maintenanceStatus;
    }
    public void setPosition(String position) {
        this.position = position;
    }

    public void setState(String state) {
        this.state = state;
    }

    public void setCurrentTask(String task) {
        this.currentTask = task;
    }
}
